﻿/*
 * XDevelopHelper
 *  @Author: XTST
 *  @Git: https://gitee.com/XTST/XUnityDevelopHelper
 *  Copyright © 2013-2018 Xiaotian Jin. All rights reserved.
 * */

namespace XDevelopHelper.FSM
{
    /// <summary>
    /// FSM状态基类
    /// </summary>
    /// <typeparam name="TOwner">FSM owner的类型</typeparam>
    public abstract class FSMState<TOwner> where TOwner : class 
    {
        #region Life Time Call

        protected internal virtual void OnInit(IFSM<TOwner> fsm) { }
        protected internal virtual void OnEnter(IFSM<TOwner> fsm) { }
        protected internal virtual void OnUpdate(IFSM<TOwner> fsm) { }
        protected internal virtual void OnLeave(IFSM<TOwner> fsm) { }

        #endregion

        #region State Changer

        protected void ChangeState<T>(IFSM<TOwner> fsm) where T : FSMState<TOwner>
        {
            fsm.ChangeState<T>();
        }

        #endregion
    }
}
